package com.ccb.lms.service;

import java.sql.SQLException;
import java.util.List;

import com.ccb.lms.facade.FacadeDAO;
import com.ccb.lms.model.Book;
import com.ccb.lms.util.BasePage;

public class BookService implements IBookService {
	private FacadeDAO facadeDAO = null;

	
	public FacadeDAO getFacadeDAO() {
		return facadeDAO;
	}

	public void setFacadeDAO(FacadeDAO facadeDAO) {
		this.facadeDAO = facadeDAO;
	}

	public boolean insertBook(Book book) throws SQLException {
		
		return facadeDAO.getBookDAO().insertBook(book);
	}

	public boolean deleteBook(Integer bookNO) throws SQLException {
		
		return facadeDAO.getBookDAO().deleteBook(bookNO);
	}

	public boolean updateBook(Book book) throws SQLException {
		
		return facadeDAO.getBookDAO().updateBook(book);
	}

	public List<Book> getAllBooks() throws SQLException {
		
		return facadeDAO.getBookDAO().getAllBooks();
	}

	public Book getBookByNO(Integer bookNO) throws SQLException {
		
		return facadeDAO.getBookDAO().getBookByNO(bookNO);
	}

	public int getBookCount() throws SQLException {
		
		return facadeDAO.getBookDAO().getBookCount();
	}

	public BasePage getBasePage(int currentPage, int showRecordNum)
			throws SQLException {
		
		return facadeDAO.getBookDAO().getBasePage(currentPage, showRecordNum);
	}

	public List<Book> getBookByPage(BasePage basePage) throws SQLException {
		
		return facadeDAO.getBookDAO().getBookByPage(basePage);
	}
	
	public List<Book> getBookByName(String bookName) throws SQLException{
		return facadeDAO.getBookDAO().getBookByName(bookName);
	}

	public List<Book> getBookByAuthor(String bookAuthor) throws SQLException {
		return facadeDAO.getBookDAO().getBookByAuthor(bookAuthor);
	}
}
